import {Component, OnInit} from '@angular/core';
import {Router} from '@angular/router';
import {AuthService} from './user/auth.service';

@Component({
  selector: 'app-root',
  template: `<router-outlet></router-outlet>`
})

export class AppComponent implements OnInit {
  public token: string;
  constructor(private authService: AuthService, private router: Router) {
  }
  ngOnInit() {
    this.token = this.authService.getTokenId();
    if (this.token != null) {
      return;
    } else {
      this.router.navigate(['/login']);
    }
  }
}
